package com.itheima.health.service;

import com.itheima.health.dto.SetMealDto;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.utils.aliyunoss.AliyunUtils;
import com.itheima.health.utils.poi.POIUtils;
import com.itheima.health.utils.redis.RedisUtil;
import com.itheima.health.utils.resources.RedisConstant;
import com.itheima.health.utils.resources.UploadUtils;
import com.itheima.health.vo.OrderSettingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@RestController
@Api(tags = "预约模块管理")
public class OrderSettingController {
    @Reference
    private OrderSettingService orderSettingService;
    //excel表格上传
    @PostMapping("ordersetting/importOrderSettings")
    public Result importOrderSettings(@RequestParam("excelFile") MultipartFile file){
        //解析上传的excel文件并封装到list集合中
            List<String[]> readExcel = POIUtils.readExcel(file);
            //调用service层的方法将表格上传至数据库
            orderSettingService.importOrderSettings(readExcel);
        return new Result(true);

    }



    //添加套餐
    @GetMapping("ordersetting/findSettingData/{year}/{month}")
    public Result findSettingData(@PathVariable("year")int year,@PathVariable("month") int month ){

        return   new Result(orderSettingService.findSettingData(year,month));
    }

    //编辑表单数据回显   setmeal/updatesetmealById
    @PutMapping("ordersetting/updateNumberByOrderDate/{number}/{settingDay}")
    public Result updateNumberByOrderDate(@PathVariable("number") int number,@PathVariable("settingDay") String settingDay ){
        return new Result(orderSettingService.updateNumberByOrderDate(number,settingDay));
    }


}
